package com.acwing.partition34;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/17 17:14
 */
public class AC3347菊花链 {

    private static final int N = 110;
    private static int[] nums = new int[N], sum = new int[N];
    private static int n = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        String[] ss = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(ss[i]);
        for (int i = 1; i <= n; i++) sum[i] += sum[i - 1] + nums[i - 1];
        //枚举每一个区间，并检查区间内是否有满足条件的花
        int ans = n;
        for (int i = 1; i <= n - 1; i++) {
            for (int j = i + 1; j <= n; j++) {
                int cnt = j - i + 1, s = sum[j] - sum[i - 1];
                //检查区间内是否存在花瓣数量为k的花
                if (s % cnt == 0 && check(i, j, s / cnt)) ans++;
            }
        }
        writer.write(ans + "\n");
        writer.flush();
    }

    private static boolean check(int l, int r, int k) {
        for (int i = l - 1; i <= r - 1; i++) {
            if (nums[i] == k) return true;
        }
        return false;
    }
}
